﻿@using SchoolPointe.RelatedContent.Helpers 

@model string
@{
    var selectedValues = Model == null ? new string[0] : Model.Split(',');

    Func<string, string> SelectedAttr = contentType => selectedValues.Contains(contentType) ? "selected" : "";
}
      
@Html.HiddenFor(m => m)
<select class="ContentTypeLimitationSelect" multiple="multiple">
    <option value="*" @SelectedAttr("*")>Any Content Type</option>
    @foreach (Orchard.ContentManagement.MetaData.Models.ContentTypeDefinition contentType in ViewBag.PossibleContentTypes)
    {
        <option value="@contentType.Name" @SelectedAttr(contentType.Name)>@contentType.DisplayName</option>
    }
</select>